﻿<Controls:MetroWindow x:Class="RazorSourceGenerator.ConnectionStringHelp"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:conv="clr-namespace:RazorSourceGenerator.Converter"                      
        xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
        Title="ConnectionStringHelp" Height="360" Width="677" WindowStartupLocation="CenterOwner" ResizeMode="NoResize">
  <Window.Resources>
    <ResourceDictionary>
      <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="CommonStyle.xaml" />
      </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
  </Window.Resources>
  <Grid>
    <Grid.Resources>
      <XmlDataProvider x:Key="connectionStrings" Source="Content/ConnectionStrings.xml"  XPath="//ConnectionString" />
      <conv:StringTrimConverter x:Key="trimConverter" />
      <SolidColorBrush x:Key="AccentColor3Brush" Color="{StaticResource AccentColor3}" />
    </Grid.Resources>
    <Grid.ColumnDefinitions>
      <ColumnDefinition Width="*"></ColumnDefinition>
      <ColumnDefinition Width="*"></ColumnDefinition>
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
      <RowDefinition Height="280"></RowDefinition>
      <RowDefinition Height="*"></RowDefinition>
    </Grid.RowDefinitions>
    <DataGrid Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Name="lstConnStr" BorderThickness="0"
                  ItemsSource="{Binding Source={StaticResource connectionStrings}}" IsReadOnly="True"
                  RowHeaderWidth="0" AutoGenerateColumns="False" HorizontalScrollBarVisibility="Disabled"
                  GridLinesVisibility="None"
                  SelectionUnit="FullRow" Background="White" >
      <DataGrid.ColumnHeaderStyle>
        <Style TargetType="DataGridColumnHeader">
          <Setter Property="FontWeight" Value="Bold" />
          <Setter Property="Background" Value="Transparent" />
          <Setter Property="Margin" Value="5" />
          <Setter Property="BorderThickness" Value="0" />
        </Style>
      </DataGrid.ColumnHeaderStyle>
      <DataGrid.RowStyle>
        <Style TargetType="DataGridRow">
          <Setter Property="BorderThickness" Value="0" />
          <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
              <Setter Property="Background" Value="{StaticResource AccentColor3Brush}" />
            </Trigger>
            <Trigger Property="IsSelected" Value="True">
              <Setter Property="Background" Value="{StaticResource AccentColorBrush}" />
            </Trigger>
          </Style.Triggers>
        </Style>
      </DataGrid.RowStyle>
      <DataGrid.CellStyle>
        <Style TargetType="DataGridCell">
          <Setter Property="BorderThickness" Value="0" />
          <Style.Triggers>
            <Trigger Property="IsSelected" Value="True">
              <Setter Property="Background" Value="Transparent" />
            </Trigger>
          </Style.Triggers>
        </Style>
      </DataGrid.CellStyle>
      <DataGrid.Columns>
        <DataGridTemplateColumn Header="Name" Width="130">
          <DataGridTemplateColumn.CellTemplate>
            <DataTemplate>
              <TextBlock Margin="5" TextWrapping="Wrap" Text="{Binding XPath=@name, Converter={StaticResource trimConverter}}"></TextBlock>
            </DataTemplate>
          </DataGridTemplateColumn.CellTemplate>
        </DataGridTemplateColumn>
        <DataGridTemplateColumn Header="Connection String" Width="525">
          <DataGridTemplateColumn.CellTemplate>
            <DataTemplate>
              <TextBlock Margin="5" TextWrapping="Wrap" Text="{Binding XPath=., Converter={StaticResource trimConverter}}"></TextBlock>
            </DataTemplate>
          </DataGridTemplateColumn.CellTemplate>
        </DataGridTemplateColumn>
      </DataGrid.Columns>
    </DataGrid>
    <DockPanel Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2">
      <Button Content="OK" Height="23" Width="75" Margin="10 0 0 0" Name="btnOK" Click="btnOK_Click" DockPanel.Dock="Left" />
      <Button Content="Cancel" Height="23" Width="75"  Margin="0 0 10 0" Name="btnCancel" Click="btnCancel_Click" DockPanel.Dock="Right" HorizontalAlignment="Right"/>
    </DockPanel>
  </Grid>
</Controls:MetroWindow>
